<template>
  <div class="address">
    <div class="address_title">
      <router-link to="/Miner">
        <div class="left iconfont icon-arrow-left"></div>
      </router-link>
      <div class="my_ads">管理收货地址</div>

      <div class="new" @click="gonewadd(item)">新建</div>
    </div>
    <div class="shipping">
      <p>我的收货地址</p>
    </div>
    <div class="adr_msg" v-for="item in addlist" :key="item.id">
      <div class="msg_left">
        <div class="msg_title">
          <p>{{ item.name }}</p>
          <p>{{ item.phone }}</p>
          <van-tag
            type="danger"
            class="default"
            v-show="item.default_set === '1' ? true : false"
            >默认</van-tag
          >
        </div>
        <div class="msg_ads">
          <p>{{ item.area_name + item.desc }}</p>
        </div>
      </div>
      <div
        class="msg_right iconfont icon-youjiantou"
        @click="newadd(item)"
      ></div>
    </div>
  </div>
</template>

<script setup>
import AddressList from "../address/components/Address_list.vue"
import { ref } from 'vue'
import { get, delcar, addToCart, post } from '../../utils/request.js'
import { Tag } from 'vant';
import { useRouter, useRoute } from 'vue-router'
let router = useRouter()


let addlist = ref()
get('/address').then(res => {
  console.log(res);
  addlist.value = res.result
})

const default_set = () => {
  get('/defalutAddress').then(res => {
    console.log(res);
  })
}


const gonewadd = (item) => {

  router.push('/New')
}

const newadd = (item) => {
  sessionStorage.setItem('addressItem', JSON.stringify(item))
  router.push('/Newaddress')
}


</script>




<style lang="scss" scoped>
.address {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}

.address_title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  height: 0.44rem;

  .left {
    margin-left: 0.184rem;
    width: 0.2rem;
    height: 0.16rem;

    font-size: 0.2rem;
    line-height: 0.16rem;
  }

  .new {
    margin-right: 0.18rem;
    width: 0.28rem;
    height: 0.2rem;

    line-height: 0.2rem;
    text-align: center;
    font-size: 0.14rem;
  }

  .my_ads {
    font-size: 16px;
    color: #333333;
    font-weight: 500;
  }
}

.shipping {
  margin: 0.16rem 0;
  width: 3.39rem;
  height: 0.2rem;
  font-size: 0.14rem;

  line-height: 0.2rem;
}

.adr_msg {
  display: flex;
  justify-content: space-around;
  align-items: center;
  width: 3.39rem;
  height: 1.04rem;

  .msg_left {
    width: 2.6rem;
    height: 0.68rem;

    .msg_title {
      display: flex;
      width: 100%;
      height: 0.2rem;
      font-size: 0.14rem;
      color: #999999;

      p:nth-child(2) {
        margin-left: 0.15rem;
      }
    }

    .msg_ads {
      margin: 0.08rem 0;
      width: 100%;
      height: 0.4rem;
      font-size: 0.14rem;
    }
  }

  .msg_right {
    width: 0.15rem;
    height: 100%;

    line-height: 1.04rem;
    text-align: center;
    font-size: 0.2rem;
  }
}

.default {
  margin-left: 0.4rem;
}
</style>